import axios from 'axios'
import store from "../store/index"

import Nprogress from "nprogress"
import 'nprogress/nprogress.css'

const Server = axios.create({
    baseURL: 'https://www.liulongbin.top:8888/api/private/v1/',
    timeout: 5000,
});
Server.interceptors.request.use(function (config) {
    // console.log(config)
    Nprogress.start()
    if (store.state.token.length > 0) {
        config.headers['Authorization'] = store.state.token;
    }
    return config
}, function (error) {
    return Promise.reject(error);
})
Server.interceptors.response.use(function (response) {
    Nprogress.start().done()
    return response.data
}, function (error) {
    return Promise.reject(error);
})

export default Server